//
//  OpinionFeedbackViewController.m
//  lmq
//
//  Created by 马田成 on 2017/4/6.
//  Copyright © 2017年 yuanxin. All rights reserved.
//

#import "OpinionFeedbackViewController.h"

@interface OpinionFeedbackViewController ()
@property (weak, nonatomic) IBOutlet UIButton *button1;
@property (weak, nonatomic) IBOutlet UIButton *button2;
@property (weak, nonatomic) IBOutlet UIButton *button3;
@property (weak, nonatomic) IBOutlet UIButton *button4;
@property (weak, nonatomic) IBOutlet UIButton *button5;
@property (weak, nonatomic) IBOutlet UITextView *textView;
@property (weak, nonatomic) IBOutlet UIButton *SubmitButton;

@property (nonatomic, assign) NSInteger type;


@end

@implementation OpinionFeedbackViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"意见与反馈";
    // Do any additional setup after loading the view from its nib.
}
- (IBAction)opinionButton:(UIButton *)sender {
    if (sender.tag == 301) {
        self.type = 1;
        
        self.button1.selected = NO;
        self.button2.selected = YES;
        self.button3.selected = NO;
        self.button4.selected = NO;
        self.button5.selected = NO;
    }else if (sender.tag == 302){
        self.type = 2;
        self.button1.selected = YES;
        self.button2.selected = NO;
        self.button3.selected = NO;
        self.button4.selected = NO;
        self.button5.selected = NO;
        
    }else if (sender.tag == 303){
        self.type = 3;
        self.button1.selected = NO;
        self.button2.selected = NO;
        self.button3.selected = YES;
        self.button4.selected = NO;
        self.button5.selected = NO;
        
    }else if (sender.tag == 304){
        self.type = 4;
        self.button1.selected = NO;
        self.button2.selected = NO;
        self.button3.selected = NO;
        self.button4.selected = YES;
        self.button5.selected = NO;
        
    }else if (sender.tag == 305){
        self.type = 5;
        self.button1.selected = NO;
        self.button2.selected = NO;
        self.button3.selected = NO;
        self.button4.selected = NO;
        self.button5.selected = YES;
        
    }
    
    
}

//提交建议
- (IBAction)submitButton:(UIButton *)sender {
    
    NSMutableDictionary *productParams=[[NSMutableDictionary alloc]init];
    
    NSString *str = [NSString stringWithFormat:@"%ld", (long)self.type];
    
    NSString *tokenStr=[PublicFunction getConfigWithKey:@"token"];
    [productParams setValue:tokenStr forKey:@"token"];
    [productParams setValue:self.textView.text forKey:@"content"];
    [productParams setValue:str forKey:@"type"];
    [[MNetworkHandler sharedInstance]conURL:My_OpinionFeedback
                                networkType:NetWorkPOST
                                     params:productParams
                                   delegate:nil
                                    showHUD:NO
                               successBlock:^(id returnData) {
                                   if ([[returnData objectForKey:@"code"]intValue]==1) {
                                       
                                       [self.navigationController popViewControllerAnimated:YES];
                                       
          
                                   }
                                   else{
                                       [PublicFunction showAlert:nil message:[returnData objectForKey:@"msg"] duration:5.0f];
                                   }
                               } failureBlock:^(NSError *error) {
                                   NSLog(@"%@",error);
                                   [PublicFunction showAlert:nil message:@"没有连接网络" duration:10.0f];
                               }];
    

    
    
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
